home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 41 / Issue 41.iso / pc / PCSoftware / Netscape 6 Official Release / nim.xpi / bin / chrome / aim.jar / content / aim / BuddyAddBuddy.js < prev    next >
Encoding:
Text File  |  2000-09-13  |  2.5 KB  |  96 lines

  1. var RDFClass = Components.classes['@mozilla.org/rdf/rdf-service;1'];
  2. var RDF = RDFClass.getService(Components.interfaces.nsIRDFService);
  3. var aim = RDF.GetDataSource("rdf:AIM");
  4. var containerClass = Components.classes['@mozilla.org/rdf/container;1'];
  5. var container = containerClass.createInstance(Components.interfaces.nsIRDFContainer);
  6. container.Init(aim, RDF.GetResource("NC:AIM/BuddyList"));
  7.  
  8. function BuildGroupFrame()    
  9. {
  10.     var a = new Array();
  11.     var i = 0;
  12.     top.a = a;
  13.  
  14.     var enumerator = container.GetElements();
  15.  
  16.     while (enumerator.hasMoreElements()) {
  17.  
  18.         var element = enumerator.getNext();
  19.         var resource = element.QueryInterface(Components.interfaces.nsIRDFResource);
  20.         dump( "Element is " + element + "\n" );
  21.         dump( "Resource is " + resource + "\n" );
  22.         var attr = aim.GetTarget(resource, 
  23.             RDF.GetResource("http://home.netscape.com/NC-rdf#Name"), true);
  24.         if (attr)
  25.             attr = attr.QueryInterface(Components.interfaces.nsIRDFLiteral);
  26.         if (attr) {
  27.             attr = attr.Value;
  28.             a[ i ] = attr;
  29.             i = i + 1;
  30.         }
  31.     }
  32.     CreateGroupList( a );
  33. }
  34.  
  35. function CreateGroupList( a )
  36. {
  37.  
  38.  
  39.     listDocument = document.getElementById("AddBuddyGroupList")
  40.     
  41.     listDocument.appendChild(document.createElement("spring"))
  42.     
  43.     for ( var i=0; i < a.length; i++ ) {
  44.         chkboxname = "checkBox" + a[i];
  45.         outputElement = document.createElement('checkbox')
  46.         outputElement.setAttribute('id',chkboxname)
  47.         outputElement.setAttribute('name',a[i])
  48.         outputElement.setAttribute('value',a[i])
  49.         listDocument.appendChild(outputElement)    
  50.         //dump("docwriting!"+ outputElement +"\n" );
  51.     }
  52.     listDocument.appendChild(document.createElement("spring"))
  53.  
  54. }
  55.  
  56. function GetCheckBoxState( a, i )
  57. {
  58.     chkboxname = "checkBox" + a[i];
  59.     chkbox = document.getElementById(chkboxname);
  60.     return( chkbox.checked );
  61. }
  62.  
  63. // for later 
  64.  
  65. function FindSelectedGroup()
  66. {
  67.     // Locate selection in setup list
  68.     // XXX There must be a better way to do this
  69.  
  70.     var selectedGroup = null;
  71.     var tree = window.tree;
  72.     dump( "Tree is " + tree + "\n" );
  73.     DumpDOM( tree );
  74.     var groups = tree.childNodes[2].childNodes;
  75.  
  76.     for (var i = 0; i != groups.length; i++) {
  77.         if (groups[i].getAttribute("selected") == "true") {
  78.             selectedGroup = groups[i].getAttribute("Name");
  79.             break;
  80.         }
  81.     }
  82.     return( selectedGroup );
  83. }
  84.  
  85. function FindBuddySelected( group, tree )
  86. {
  87.     var buddyList;
  88.     
  89.     if ( tree )
  90.         buddyList = tree.selectedItems;
  91.  
  92.     if ( !buddyList || buddyList.length != 1 )
  93.         return null;
  94.     return( buddyList[0].getAttribute("Name") );
  95. }
  96.